package com.objetdirect.gwt.umldrawer.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.HistoryListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
@SuppressWarnings("deprecation")
public class OProDesUML implements EntryPoint, HistoryListener {

	private VerticalPanel mainPanel = new VerticalPanel();

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		History.newItem("Home");
		History.addHistoryListener(this);
		History.onHistoryChanged("Home");

		mainPanel.setStyleName("myProgram");
		RootPanel.get().add(mainPanel);
	}

	@Override
	public void onHistoryChanged(String historyToken) {
		
		mainPanel.clear();
		mainPanel.setStyleName("myProgram");
		if (historyToken.equals("Home") || historyToken.equals("")) {
			mainPanel.add(new HomePageContent().getPageContent());
		} 
		else if (historyToken.equals("SignIn")) {
			mainPanel.add(new SignInPageContent().getPageContent());
		} 
		else if (historyToken.equals("SignUp")) {
			mainPanel.add(new SignUpPageContent().getPageContent());
		} 
		else if (historyToken.equals("AboutUs")) {
			mainPanel.add(new AboutUsPageContent().getPageContent());
		} 
		else if (historyToken.equals("Tutorials")) {
			mainPanel.add(new TutorialsPageContent().getPageContent());
		} 
		else if (historyToken.equals("Samples")) {
			mainPanel.add(new SamplesPageContent().getPageContent());
		} 
		else if (historyToken.equals("TermsOfUse")) {
			mainPanel.add(new TermsOfUsePageContent().getPageContent());
		} 
		else if (historyToken.equals("Account")) {
			mainPanel.add(new AccountPageContent().getPageContent());
		}
		else if (historyToken.equals("UMLDrawer")) {
			mainPanel.setStyleName("UMLDrawer");
			mainPanel.add(new UMLDrawerPage().getUMLDrawerPage());
		}
	}
}
